/*
 *  reader.cpp
 *  initiativeTracker
 *
 *  Created by Sam Jaffe on 5/5/12.
 *  Copyright 2012 WPI. All rights reserved.
 *
 */

#include <sstream>
#include <iostream>
#include <stdlib.h>
#include "reader.h"

std::string readLine() {
    std::string s;
    std::cin >> s;
    return s;
}

int readInt(const std::string message) {
    std::cout << message + ": ";
    
    std::string s;
    std::stringstream ss;
    int val;
    
    while (true) {
        std::cin >> s;
        val = atoi(s.c_str());
        ss << val;
        
        if (ss.str().compare(s) == 0)
            return val;
        else {
            std::cout << "Error: NaN\n" << message + ": ";
        }
    }
}

double readDouble(const std::string message) {
    std::cout << message + ": ";
    
    std::string s;
    std::stringstream ss;
    double val;
    
    while (true) {
        std::cin >> s;
        val = atoi(s.c_str());
        ss << val;
        
        if (ss.str().compare(s) == 0)
            return val;
        else {
            std::cout << "Error: NaN\n" << message + ": ";
        }
    }
}
